package com.itheima.easy.controller;

import com.itheima.easy.base.AjaxResult;
import com.itheima.easy.dto.PendingTasksDto;
import com.itheima.easy.service.PendingTasksService;
import com.itheima.easy.utils.UserThreadLocal;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author sjqn
 * @date 2023/6/21
 */
@RestController
@RequestMapping("/pending_tasks")
@Api(tags = "待办")
public class PendingTasksController {

    @Autowired
    private PendingTasksService pendingTasksService;


    @PostMapping("/selectByPage")
    @ApiOperation(value = "查询待办", notes = "传入退住对象")
    public AjaxResult selectByPage(@RequestBody PendingTasksDto pendingTasksDto){
        //只查询有当前登录人的任务
        Long userId = UserThreadLocal.getMgtUserId();
        if(pendingTasksDto.getReqType() == 0){
            pendingTasksDto.setAssigneeId(userId);
        }else {
            pendingTasksDto.setApplicatId(userId);
        }
        return pendingTasksService.selectByPage(pendingTasksDto);
    }
}
